package com.situ.water_BE.service.impl;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.situ.water_BE.mapper.BeCommentMapper;
import com.situ.water_BE.mapper.BeHistoryMapper;
import com.situ.water_BE.mapper.BeOrderMapper;
import com.situ.water_BE.mapper.BeOrderuserMapper;
import com.situ.water_BE.pojo.BeComment;
import com.situ.water_BE.pojo.BeHistory;
import com.situ.water_BE.pojo.BeOrder;
import com.situ.water_BE.pojo.BeOrderuser;
import com.situ.water_BE.service.BeCommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author Angel
 * @since 2020-12-01
 */
@Service
public class BeCommentServiceImpl extends ServiceImpl<BeCommentMapper, BeComment> implements BeCommentService {
    @Autowired
    private BeCommentMapper dao;
    @Autowired
    private BeOrderMapper beOrderDao;
    @Autowired
    private BeHistoryMapper beHistoryDao;
    @Autowired
    private BeOrderuserMapper beOrderuserDao;
    @Override
    public List<BeComment> queryAll(QueryWrapper<BeComment> wrapper) {
        return dao.selectList(wrapper);
    }

    @Override
    public List<Map> queryAllSQL(String orderNo) {
        return dao.queryAllSQL(orderNo);
    }

    @Override
    public int addBeComment(BeComment beComment) {
        beComment.setDatee(new Date());
        return dao.insert(beComment);
    }

    @Override
    public int updateBeComment(BeComment beComment) {
        return dao.updateById(beComment);
    }

    @Override
    public int deleteBeComment(Integer id) {
        return dao.deleteById(id);
    }

    @Override
    public BeOrder queryByBeOrder(String orderNo) {
        return beOrderDao.selectById(orderNo);
    }
    @Override
    public Map queryByBeOrderSQL(String orderNo){
        List<BeHistory> orderNo1 = beHistoryDao.selectList(new QueryWrapper<BeHistory>().eq("OrderNo", orderNo));
        Map map = dao.queryByBeOrderSQL(orderNo);
        map.put("guan",orderNo1.get(orderNo1.size()-1).getDatee());
        return map;
    }

    @Override
    public List<BeOrderuser> queryListBeOrderUser(QueryWrapper<BeOrderuser> wrapper) {
        return beOrderuserDao.selectList(wrapper);
    }

    @Override
    public List<Map> queryListBeOrderUserSQL(String orderNo) {
        return dao.queryListBeOrderUserSQL(orderNo);
    }
}
